﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Developer.Core.FrameWork.MiddlePlatformService.Options
{
    /// <summary>
    /// 中台统一结果处理
    /// </summary>
    public class MiddlePlatformResult
    {
        public string Success { get; set; }
        public string ErrorInfo { get; set; }
        public IDictionary<string, object> ResultDic { get; set; } //单个返回结果
        public IList<IDictionary<string, object>> ResultList { get; set; } // 结果集返回
        public dynamic Result { get; set; } // 返回动态结果

        public MiddlePlatformResult()
        {
            this.ResultDic = new Dictionary<string, object>();
            this.ResultList = new List<IDictionary<string, object>>();
        }

        public MiddlePlatformResult(string JsonStr)
        {
            MiddlePlatformResult result = JsonConvert.DeserializeObject<MiddlePlatformResult>(JsonStr);
        }

        public static MiddlePlatformResult JsonToMiddlePlatformResult(string JsonStr)
        {
            MiddlePlatformResult result = JsonConvert.DeserializeObject<MiddlePlatformResult>(JsonStr);
            return result;
        }

        public MiddlePlatformResult(string success, string ErrorInfo)
        {
            this.Success = success;
            this.ErrorInfo = ErrorInfo;
            this.ResultDic = new Dictionary<string, object>();
            this.ResultList = new List<IDictionary<string, object>>();
        }

        public MiddlePlatformResult(string success, string ErrorInfo, IDictionary<string, object> resultDic, IList<IDictionary<string, object>> resultList)
        {
            this.Success = success;
            this.ErrorInfo = ErrorInfo;
            this.ResultDic = resultDic;
            this.ResultList = resultList;
        }
         
    }
}
